package com.example.demo.Service.impl;

//         佛祖保佑       永无BUG     永不修改

import com.example.demo.Service.userService;
import com.example.demo.dao.UserDao;
import com.example.demo.pojo.UserDO;
import com.example.demo.pojo.flower;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceimpl implements userService {

    @Autowired
    private UserDao userDao;


    /**
     * 用户登录
     * @param username
     * @param password
     * @return
     */
    @Override
    public UserDO  loginUser(String username, String password) {
        System.out.println(userDao.loginUser(username, password) + "正在登录");
        UserDO  user = userDao.loginUser(username, password);
        if (user != null) {
            return userDao.loginUser(username, password);
        } else {
            return null;
        }
    }

    /**
     * override
     *重写了父类接口中的方法
     * @param userDO
     * @return
     */
    @Override
    public boolean setUser(UserDO userDO) {
        UserDO userDO1 = userDao.getUserNameByName(userDO.getUsername());
        if (userDO1 == null) {
            return userDao.setUser(userDO);
        }
        return false;
    }

    /**
     * 上传鲜花
     * @param flower
     * @return
     */
    @Override
    public boolean upload(flower flower,String flowers, String picture) {
        return userDao.upload(flower,flowers,picture);
    }

}
